﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPFCollection
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        WB scriptobj = new WB();
        public MainWindow()
        {
            InitializeComponent();

            scriptobj.Mw = this;

            //浏览器控件加载完成后发生
            wb.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(wb_LoadCompleted);
            Loaded += new RoutedEventHandler(MainWindow_Loaded);
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            wb.ObjectForScripting = scriptobj;
            wb.ObjectForScripting = scriptobj;
        }

        void wb_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
        {
            string fileContent = System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "js.js");

            wb.InvokeScript("eval", fileContent);


        }

        //转到
        private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
          wbcopy.Source=  wb.Source = new Uri(wbSource.Text);
        }


    }
}
